home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / lisp / kcl / kcl.lha / uts / hasegawa / kcl.c < prev    next >
C/C++ Source or Header  |  1987-05-08  |  736b  |  41 lines

  1. #define KCL_SELF                "/usr2/kcl2/unixport/saved_kcl"
  2. #define SYSTEM_DIRECTORY        "/usr2/kcl2/unixport/"
  3.  
  4. #include <stdio.h>
  5. #include <signal.h>
  6.  
  7. #define    COMSIZ    1024
  8.  
  9. main()
  10. {
  11.     int in[2];
  12.     int out[2];
  13.     char command[COMSIZ];
  14.     char buf[4];
  15.  
  16.     pipe(in);
  17.     pipe(out);
  18.     if (in[1] != 4 || out[0] != 5) {
  19.         fprintf(stderr, "Can't get a pipe.\n");
  20.         exit(1);
  21.     }
  22.     fflush(stdout);
  23.     if (fork() != 0) {
  24.         close(in[0]);
  25.         close(out[1]);
  26.         if (execl(KCL_SELF, KCL_SELF, SYSTEM_DIRECTORY, 0) < 0) {
  27.             fprintf(stderr, "Can't exec KCL.\n");
  28.             exit(1);
  29.         }
  30.     }
  31.     signal(SIGINT, SIG_IGN);
  32.     close(in[1]);
  33.     close(out[0]);
  34.     for (;;) {
  35.         if (read(in[0], command, COMSIZ) <= 0)
  36.             exit(0);
  37.         buf[0] = system(command);
  38.         write(out[1], buf, 1);
  39.     }
  40. }
  41.